package com.loren.demo03.tcp2.codec;

import com.loren.demo03.tcp0.MessageCodec;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class CustomDecoder extends ByteToMessageDecoder {

    /**
     * 默认一次会读取2048个字节，如果内容总长度为2049，那么会分两次读取
     */
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
        new MessageCodec().decode(in, out);
    }
}
